package redis

import (
	"Godzilla/conf/databases"
	"github.com/gomodule/redigo/redis"
	"log"
	"strconv"
)

func NewRedisConn() (conn redis.Conn, err error) {
	var (
		Host		string
		Port		string
		GetNum		string
		Num			int
		error		error
	)


	//redis 使用案例
	//port := databases.GetRedisConfig("Port")
	//log.Println(port)
	//log.Println("111")
	//redis, err:= redis.NewRedisConn()
	//defer redis.Close()
	//if err != nil {
	//	log.Println(err)
	//}
	//redis.Do("SET", "ggg", "你好")
	//
	//key, err := redis2.String(redis.Do("GET", "ggg"))
	//
	//if err != nil {
	//	log.Println(err)
	//}
	//log.Println(key)


	Host   = databases.GetRedisConfig("Host")
	Port   = databases.GetRedisConfig("Port")
	GetNum = databases.GetRedisConfig("Num")
	Num, error = strconv.Atoi(GetNum)
	if error != nil {
		log.Println(error)
	}
	log.Println(Host)
	log.Println(Port)
	log.Println(Num)

	conn, err =  redis.Dial("tcp",
		Host + ":" + Port,
		redis.DialDatabase(Num),
		)
	if err != nil {
		log.Println(err)
	}
	return conn, err


}
